package acwing.prefixSumAndDifferenceArray;

import java.util.Scanner;

public class prefixSum {
    static int N = 100010;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[N];
        int[] sum = new int[N];

        for (int i = 1 ; i <= n; i++){
            arr[i] = sc.nextInt();
            sum[i] = sum[i - 1] + arr[i];
        }
        while(m-- != 0){
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(sum[r] - sum[l - 1]);
        }
    }
}
